#ifndef LIST_H
#define LIST_H

#ifdef __cplusplus
extern "C" {
#endif

	typedef struct list_t
	{
		unsigned char* 			pbuffer;
		unsigned char				length;
		unsigned char				compacity;
	}list_t;


#define list_length(plist)												((plist)->length)
#define list_is_empty(plist)											((plist)->length == 0)
#define list_is_full(plist)												((plist)->length == (plist)->compacity)
#define list_clear(plist)													(plist)->length = 0
#define list_init(plist, buffer, buffer_size)			(plist)->pbuffer = (buffer);(plist)->length = 0;(plist)->compacity = (buffer_size)
#define list_get(plist, index)										(plist)->pbuffer[(index)]
#define list_set(plist, index, value)							(plist)->pbuffer[(index)] = (value)
#define list_first(plist)													(plist)->pbuffer[0]
#define list_last(plist)													(plist)->pbuffer[(plist)->length - 1]
#define list_push(plist, value)										(plist)->pbuffer[(plist)->length++] = (value)
#define list_pop(plist)														(plist)->pbuffer[--((plist)->length)]
#define list_enque(plist, value)									list_insert(plist,(plist)->length)
#define list_deque(plist)													list_remove(plist, 0)




unsigned char list_search(list_t* plist, unsigned char value);
void list_insert(list_t* plist, unsigned char index, unsigned char value);
void list_remove(list_t* plist, unsigned char index);

#ifdef __cplusplus
}
#endif

#endif /* LIST_H */